<template>
  <div class="carditem" @click.stop="onItem(item1)">
    <van-card :origin-price="item1.origin_price" :price="item1.price" :desc="item1.spec" :title="item1.name" :thumb="item1.small_image">
    <template #footer>
        <img src="../assets/img/tabbar/shoppingcart_selected.png" alt="" @click.stop="onShop(item1)">
    </template>
    </van-card>
  </div>
</template>
<script>
import { Toast } from 'vant';
export default {
    name:"CardItem",
    props:["item1"],
    data() {
      return {
        // list:[],
        // allArr:[]
      }
    },
    methods: {
      onItem(val){
            // console.log(val);
          this.$store.commit("onItem",val);
          this.$router.push("/item");
      },
      onShop(item){
        if(localStorage.getItem("taken")){
            this.$store.commit("onList",item);
            Toast("加入购物车");
        }else{
          Toast("请前往登录");
          this.$router.push("login");
        }
        
      }
    },
}
</script>

<style>
    img{
        width: 0.3rem;
        height: 0.3rem;
    }
</style>